<?php if (!defined('TL_ROOT')) die('You can not access this file directly!');

/**
 * TYPOlight webCMS
 * Copyright (C) 2005 Leo Feyer
 *
 * This program is free software: you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation, either
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this program. If not, please visit the Free
 * Software Foundation website at http://www.gnu.org/licenses/.
 *
 * PHP version 5
 * @copyright  Softleister 2008 
 * @author     Softleister <info@softleister.de> 
 * @package    Ticker 
 * @license    LGPL 
 * @filesource
 */


/**
 * Load tl_content language file
 */
$this->loadLanguageFile('tl_content');


/**
 * Table tl_order_detail 
 */
$GLOBALS['TL_DCA']['tl_order_detail'] = array
(

	// Config
	'config' => array
	(
		'dataContainer'               => 'Table',
		'ptable'                      => 'tl_orders',
		'enableVersioning'            => true		
	),

	// List
	'list' => array
	(
		'sorting' => array
		(
			'mode'                    => 4,
			'fields'                  => array('id DESC'),
			'headerFields'            => array('orderno', 'payment', 'total_paid_real', 'total_catolog', 'total_shipping', 'total_wrapping'),
			'panelLayout'             => 'filter;search,limit',
			'child_record_callback'   => array('tl_order_detail', 'listOrderDetails')
		),
		'global_operations' => array
		(
			'all' => array
			(
				'label'               => &$GLOBALS['TL_LANG']['MSC']['all'],
				'href'                => 'act=select',
				'class'               => 'header_edit_all',
				'attributes'          => 'onclick="Backend.getScrollOffset();"'
			)
		),
		'operations' => array
		(
			'delete' => array
			(
				'label'               => &$GLOBALS['TL_LANG']['tl_order_detail']['delete'],
				'href'                => 'act=delete',
				'icon'                => 'delete.gif',
				'attributes'          => 'onclick="if (!confirm(\'' . $GLOBALS['TL_LANG']['MSC']['deleteConfirm'] . '\')) return false; Backend.getScrollOffset();"'
			),
			'show' => array
			(
				'label'               => &$GLOBALS['TL_LANG']['tl_order_detail']['show'],
				'href'                => 'act=show',
				'icon'                => 'show.gif'
			)
		)
	),

	// Palettes
	'palettes' => array
	(
		'default'                     => '{order_legend},id,pid;'
	),

	// Fields
	'fields' => array
	(
		'id' => array
		(
			'label'                   => &$GLOBALS['TL_LANG']['tl_order_detail']['id'],
			'exclude'                 => true,
			'search'                  => true,
			'inputType'               => 'text',
			'eval'                    => array('mandatory'=>true, 'maxlength'=>255)
		),
		'pid' => array
		(
			'label'                   => &$GLOBALS['TL_LANG']['tl_order_detail']['pid'],
			'exclude'                 => true,
			'search'                  => true,
			'inputType'               => 'text',
			'eval'                    => array('mandatory'=>true, 'maxlength'=>255)
		),
		'product_catalog_id' => array
		(
			'label'                   => &$GLOBALS['TL_LANG']['tl_order_detail']['product_catalog_id'],
			'exclude'                 => true,
			'search'                  => true,
			'inputType'               => 'text',
			'eval'                    => array('mandatory'=>true, 'maxlength'=>255)
		),
		'product_attribute' => array
		(
			'label'                   => &$GLOBALS['TL_LANG']['tl_order_detail']['product_attribute'],
			'exclude'                 => true,
			'search'                  => true,
			'inputType'               => 'text',
			'eval'                    => array('mandatory'=>true, 'maxlength'=>255)
		),
		'product_name' => array
		(
			'label'                   => &$GLOBALS['TL_LANG']['tl_order_detail']['product_name'],
			'exclude'                 => true,
			'search'                  => true,
			'inputType'               => 'text',
			'eval'                    => array('mandatory'=>true, 'maxlength'=>255)
		),
		'product_quantity' => array
		(
			'label'                   => &$GLOBALS['TL_LANG']['tl_order_detail']['product_quantity'],
			'exclude'                 => true,
			'search'                  => true,
			'inputType'               => 'text',
			'eval'                    => array('mandatory'=>true, 'maxlength'=>255)
		),
		'product_price' => array
		(
			'label'                   => &$GLOBALS['TL_LANG']['tl_order_detail']['product_price'],
			'exclude'                 => true,
			'search'                  => true,
			'inputType'               => 'text',
			'eval'                    => array('mandatory'=>true, 'maxlength'=>255)
		),
		'is_package' => array
		(
			'label'                   => &$GLOBALS['TL_LANG']['tl_order_detail']['is_package'],
			'exclude'                 => true,
			'search'                  => true,
			'inputType'               => 'text',
			'eval'                    => array('mandatory'=>true, 'maxlength'=>255)
		)
	)
);



/**
 * Class tl_order_detail
 *
 * Provide miscellaneous methods that are used by the data configuration array.
 * @copyright  Softleister 2008
 * @author     Softleister <info@softleister.de>
 * @package    Ticker
 */
class tl_order_detail extends Backend
{
	/**
	 * Import the back end user object
	 */
	public function __construct()
	{
		parent::__construct();
		$this->import('BackendUser', 'User');
	}
	
	/**
	 * Add the type of input field
	 * @param array
	 * @return string
	 */
	public function listOrderDetails($arrRow)
	{
		return '
<div class="cte_type"><strong>' . $arrRow['product_name'] . '</strong> - ' . $arrRow['product_price'] . '</div>
<div class="limit_height' . (!$GLOBALS['TL_CONFIG']['doNotCollapse'] ? ' h64' : '') . ' block">
' . $arrRow['product_reference'] . '
</div>' . "\n";
	}
}

?>